/**
 * 
 */
package com.jie.eclipse.pan.editors.form;

import org.eclipse.swt.SWT;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.FileEditorInput;

import com.jie.eclipse.pan.editors.PllMasterDetailsBlock;
import com.jie.eclipse.pan.xml.XMLNode;

/**
 * @author yanjie
 * 
 */
public class PllPage extends BasePage {
	public static final String ID = "com.jie.eclipse.pan.editors.page.pllpage";
	private PllMasterDetailsBlock block;
	

	private XMLNode pageNode = null;
	/**
	 * @param editor
	 * @param id
	 * @param title
	 */
	public PllPage(FormEditor editor) {
		super(editor, ID, "配置设计");
		block = new PllMasterDetailsBlock(this);
	}

	@Override
	protected void createFormContent(IManagedForm managedForm) {
		// 通过managedForm对象获得表单工具对象
		FormToolkit toolkit = managedForm.getToolkit();
		// 通过managedForm对象获得ScrolledForm可滚动的表单对象
		ScrolledForm form = managedForm.getForm();
		// 设置表单文本
		form.setText("页面设计");
		form.getBody().setBackground(
				form.getBody().getDisplay()
						.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
		
		this.block.createContent(managedForm);
	}
	
	public XMLNode getPageNode(){
		if(this.pageNode == null){
			FileEditorInput fi = (FileEditorInput)this.getEditor().getEditorInput();
			//this.pageNode = XMLNode.Load(fi.getFile().getFullPath().toFile().getAbsolutePath());
			this.pageNode = XMLNode.Load(fi.getFile().getLocation().toString());
		}
		return this.pageNode;
	}
	
	public void reloadPageNode(){
		FileEditorInput fi = (FileEditorInput)this.getEditor().getEditorInput();
		this.pageNode = XMLNode.Load(fi.getFile().getLocation().toString());
	}
	
	public PllMasterDetailsBlock getBlock() {
		return block;
	}
}
